// process.on('beforeExit', (code) => {
//     console.log('进程 beforeExit 事件的代码: ', code);
//   });
  
process.on('exit', (code) => {
   console.log('进程 exit 事件的代码: ', code);
});



// //process.exit();



// process.on('disconnect', (code) => {
//     console.log('进程 disconnect 事件的代码: ', code);
//     });



let users={
	"admin":"123",
	"user1":"321",
	"user2":"213"
}
let username="";
process.stdout.write("请输入用户名:");
process.stdin.on('data',(input)=>{
	input=input.toString().trim();
	if(!username){
		if(Object.keys(users).indexOf(input)===-1){
			process.stdout.write('用户名不存在'+'\n');
			process.stdout.write("请输入用户名:");
			username="";
		}
		else 
		{
			process.stdout.write("请输入密码:");
			username=input;
		}
	}
	//输入密码
	else{
		if(input===users[username]){
            console.log("登陆成功\n换行实时");
		}
		else{
			process.stdout.write("请输入密码"+"\n");
		}
		
	}

})